/*
 * @(#)GameDAO.java $version 2011. 10. 14
 * 
 * Copyright 2011 NHN Corp. All rights Reserved.
 * NHN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.hangame.mbl.dao.game;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.hangame.mbl.model.Game;
import com.hangame.mbl.model.GameGenre;
import com.hangame.mbl.model.GameList;
import com.hangame.mbl.model.GameOsInfo;
import com.hangame.mbl.model.GameSimpleInfo;
import com.hangame.mbl.model.ScreenShot;
import com.hangame.mbl.model.Theme;
import com.nhncorp.lucy.db.dao.BaseSqlMapDAO;

// TODO: Auto-generated Javadoc
/**
 * The Class GameDAO.
 *
 * @author NHN
 */
@SuppressWarnings("unchecked")
public class GameDAO extends BaseSqlMapDAO {
	
	/**
	 * Instantiates a new game dao.
	 */
	public GameDAO() {
		setResourceId("mobilewww");
	}

	/**
	 * Select game list.
	 * 
	 * @param genreCode the genre code
	 * @param offset the offset
	 * @param count the count
	 * @param isAll the is all
	 * @return the array list
	 * @throws SQLException the sQL exception
	 */
	public ArrayList<GameList> selectGameList(String genreCode, int offset, int count, boolean isAll) throws SQLException {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("genreCode", genreCode);
		params.put("offset", offset);
		params.put("count", count);
		params.put("isAll", isAll);

		return (ArrayList<GameList>)queryForList("com.hangame.mbl.www.game.selectGameList", params);
	}

	/**
	 * Select game list count.
	 * 
	 * @param genreCode the genre code
	 * @return the integer
	 * @throws SQLException the sQL exception
	 */
	public Integer selectGameListCount(String genreCode) throws SQLException {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("genreCode", genreCode);
		return (Integer)queryForObject("com.hangame.mbl.www.game.selectGameListCount", params);
	}

	/**
	 * Select recommend game list.
	 * 
	 * @return the list
	 * @throws SQLException the sQL exception
	 */
	public List<GameList> selectRecommendGameList() throws SQLException {
		return (List<GameList>)queryForList("com.hangame.mbl.www.game.selectRecommendGameList");
	}

	/**
	 * Select theme game list.
	 * 
	 * @param themeId the theme id
	 * @param offset the offset
	 * @param count the count
	 * @return the array list
	 * @throws SQLException the sQL exception
	 */
	@SuppressWarnings("rawtypes")
	public ArrayList<GameList> selectThemeGameList(int themeId, int offset, int count) throws SQLException {
		Map params = new HashMap();
		params.put("themeId", themeId);
		params.put("offset", offset);
		params.put("count", count);

		return (ArrayList<GameList>)queryForList("com.hangame.mbl.www.game.selectThemeGameList", params);
	}

	/**
	 * Select related game list.
	 * 
	 * @param gameNo the game no
	 * @return the array list
	 * @throws SQLException the sQL exception
	 */
	public ArrayList<GameList> selectRelatedGameList(int gameNo) throws SQLException {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("gameNo", gameNo);

		return (ArrayList<GameList>)queryForList("com.hangame.mbl.www.game.selectRelatedGameList", params);
	}

	/**
	 * Select game detail info.
	 * 
	 * @param gameNo the game no
	 * @return the game
	 * @throws SQLException the sQL exception
	 */
	public Game selectGameDetailInfo(int gameNo) throws SQLException {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("gameNo", gameNo);

		return (Game)queryForObject("com.hangame.mbl.www.game.selectGameDetailInfo", params);
	}

	/**
	 * Select screen shot list.
	 * 
	 * @param gameNo the game no
	 * @return the list
	 * @throws SQLException the sQL exception
	 */
	public List<ScreenShot> selectScreenShotList(int gameNo) throws SQLException {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("gameNo", gameNo);

		return (List<ScreenShot>)queryForList("com.hangame.mbl.www.game.selectScreenShotList", params);
	}

	/**
	 * Select game gnr list.
	 * 
	 * @return the array list
	 * @throws SQLException the sQL exception
	 */
	public ArrayList<GameGenre> selectGameGnrList() throws SQLException {
		return (ArrayList<GameGenre>)queryForList("com.hangame.mbl.www.game.selectGameGnrList");
	}

	/**
	 * Select all game simple list.
	 * 
	 * @return the array list
	 * @throws SQLException the sQL exception
	 */
	public ArrayList<GameSimpleInfo> selectAllGameSimpleList() throws SQLException {
		return (ArrayList<GameSimpleInfo>)queryForList("com.hangame.mbl.www.game.selectAllGameSimpleList");
	}

	/**
	 * Insert star rating log.
	 * 
	 * @param params the params
	 * @throws SQLException the sQL exception
	 */
	public void insertStarRatingLog(HashMap<String, String> params) throws SQLException {
		insert("com.hangame.mbl.www.game.insertStarRatingLog", params);
	}

	/**
	 * Select star rating.
	 * 
	 * @param params the params
	 * @return the hash map
	 * @throws SQLException the sQL exception
	 */
	public HashMap<String, String> selectStarRating(HashMap<String, String> params) throws SQLException {
		return (HashMap<String, String>)queryForObject("com.hangame.mbl.www.game.selectStarRating", params);
	}

	/**
	 * Insert star rating.
	 * 
	 * @param params the params
	 * @throws SQLException the sQL exception
	 */
	@SuppressWarnings("rawtypes")
	public void insertStarRating(HashMap params) throws SQLException {
		insert("com.hangame.mbl.www.game.insertStarRating", params);
	}

	/**
	 * Update star rating.
	 * 
	 * @param params the params
	 * @throws SQLException the sQL exception
	 */
	@SuppressWarnings("rawtypes")
	public void updateStarRating(HashMap params) throws SQLException {
		update("com.hangame.mbl.www.game.updateStarRating", params);
	}

	/**
	 * Select star rating log count by id.
	 * 
	 * @param params the params
	 * @return the integer
	 * @throws SQLException the sQL exception
	 */
	@SuppressWarnings("rawtypes")
	public Integer selectStarRatingLogCountById(HashMap params) throws SQLException {
		return (Integer)queryForObject("com.hangame.mbl.www.game.selectStarRatingLogCountById", params);
	}

	/**
	 * Select star rating log by id.
	 * 
	 * @param params the params
	 * @return the float
	 * @throws SQLException the sQL exception
	 */
	@SuppressWarnings("rawtypes")
	public Float selectStarRatingLogById(HashMap params) throws SQLException {
		return (Float)queryForObject("com.hangame.mbl.www.game.selectStarRatingLogById", params);
	}
	
	/**
	 * Select big scr thumb by small scr thumb.
	 * 
	 * @param sThumbId the s thumb id
	 * @return the string
	 * @throws SQLException the sQL exception
	 */
	public String selectBigScrThumbBySmallScrThumb(int sThumbId) throws SQLException {
		return (String)queryForObject("com.hangame.mbl.www.game.selectBigScrThumbBySmallScrThumb", sThumbId);
	}

	/**
	 * 테마 목록을 가져옴.
	 * 
	 * @return the list
	 * @throws SQLException the sQL exception
	 * @return
	 */
	public List<Theme> selectThemeList() throws SQLException {
		return (List<Theme>)queryForList("com.hangame.mbl.www.game.selectThemeList");
	}

	/**
	 * Select theme by theme id.
	 * 
	 * @param themeId the theme id
	 * @return the theme
	 * @throws SQLException the sQL exception
	 */
	public Theme selectThemeByThemeId(int themeId) throws SQLException {
		return (Theme)queryForObject("com.hangame.mbl.www.game.selectThemeByThemeId", themeId);
	}

	/**
	 * Select tot cnt theme game list.
	 * 
	 * @param themeId the theme id
	 * @return the integer
	 * @throws SQLException the sQL exception
	 */
	public Integer selectTotCntThemeGameList(Integer themeId) throws SQLException {
		return (Integer)queryForObject("com.hangame.mbl.www.game.selectTotCntThemeGameList", themeId);
	}
	
	/**
	 * 한게임 앱 오픈 여부.
	 * 
	 * @return the string
	 * @throws SQLException the sQL exception
	 */
	public String selectHangameAppOpen() throws SQLException {
		return (String)queryForObject("com.hangame.mbl.www.game.selectHangameAppOpen");
	}

	/**
	 * Select game os info.
	 * 
	 * @param gameNoArray the game no array
	 * @return the list
	 * @throws SQLException the sQL exception
	 */
	public List<GameOsInfo> selectGameOsInfo(int[] gameNoArray) throws SQLException {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("gameNos", gameNoArray);
		
		return (List<GameOsInfo>)queryForList("com.hangame.mbl.www.game.selectGameOsInfo", params);
	}
}
